// Model type definitions
export enum ModelType {
  GPT4 = "gpt-4",
  GPT35 = "gpt-3.5-turbo",
  CLAUDE = "claude-3",
  QWEN = "qwen-max",         // 通义千问
  ERNIE = "ernie-bot-4",     // 文心一言
  SPARK = "spark-v3",        // 讯飞星火
  KIMI = "moonshot-v1",      // Kimi
  DEEPSEEK = "deepseek-chat", // DeepSeek
  DOUBAO = "doubao-pro",     // 豆包
  HUNYUAN = "hunyuan-pro"    // 混元
}

export interface ModelInfo {
  id: ModelType;
  name: string;
  provider: string;
  icon?: string;
  description: string;
  maxTokens: number;
  costPerToken: number;
  available: boolean;
}

export interface ModelParameters {
  temperature: number;      // 0-1, 控制随机性
  topP: number;            // 0-1, 核采样
  maxTokens: number;       // 最大生成长度
  presencePenalty?: number; // -2到2, 主题重复惩罚
  frequencyPenalty?: number; // -2到2, 词频惩罚
}

export interface ParameterPreset {
  id: string;
  name: string;
  description: string;
  parameters: ModelParameters;
  isCustom?: boolean;
}

export interface ModelCapabilities {
  maxTokens: number;
  languages: string[];
  specialties: string[];
  costPerToken: number;
  responseTime: 'fast' | 'medium' | 'slow';
}

export const MODEL_INFO: Record<ModelType, ModelInfo> = {
  [ModelType.GPT4]: {
    id: ModelType.GPT4,
    name: "GPT-4",
    provider: "OpenAI",
    description: "最强大的模型，适合复杂任务",
    maxTokens: 8192,
    costPerToken: 0.00003,
    available: true
  },
  [ModelType.GPT35]: {
    id: ModelType.GPT35,
    name: "GPT-3.5 Turbo",
    provider: "OpenAI",
    description: "快速高效，适合日常任务",
    maxTokens: 4096,
    costPerToken: 0.000001,
    available: true
  },
  [ModelType.CLAUDE]: {
    id: ModelType.CLAUDE,
    name: "Claude 3",
    provider: "Anthropic",
    description: "擅长分析和推理",
    maxTokens: 100000,
    costPerToken: 0.00002,
    available: true
  },
  [ModelType.QWEN]: {
    id: ModelType.QWEN,
    name: "通义千问",
    provider: "阿里云",
    description: "中文理解能力强",
    maxTokens: 6000,
    costPerToken: 0.00001,
    available: true
  },
  [ModelType.ERNIE]: {
    id: ModelType.ERNIE,
    name: "文心一言",
    provider: "百度",
    description: "中文创作能力优秀",
    maxTokens: 4096,
    costPerToken: 0.000012,
    available: true
  },
  [ModelType.SPARK]: {
    id: ModelType.SPARK,
    name: "讯飞星火",
    provider: "科大讯飞",
    description: "多模态理解能力",
    maxTokens: 4096,
    costPerToken: 0.000015,
    available: true
  },
  [ModelType.KIMI]: {
    id: ModelType.KIMI,
    name: "Kimi",
    provider: "月之暗面",
    description: "超长上下文处理",
    maxTokens: 128000,
    costPerToken: 0.000012,
    available: true
  },
  [ModelType.DEEPSEEK]: {
    id: ModelType.DEEPSEEK,
    name: "DeepSeek",
    provider: "深度求索",
    description: "代码和数学能力强",
    maxTokens: 4096,
    costPerToken: 0.000008,
    available: true
  },
  [ModelType.DOUBAO]: {
    id: ModelType.DOUBAO,
    name: "豆包",
    provider: "字节跳动",
    description: "对话流畅自然",
    maxTokens: 4096,
    costPerToken: 0.00001,
    available: true
  },
  [ModelType.HUNYUAN]: {
    id: ModelType.HUNYUAN,
    name: "混元",
    provider: "腾讯",
    description: "多领域知识丰富",
    maxTokens: 4096,
    costPerToken: 0.000011,
    available: true
  }
};

export const MODEL_CAPABILITIES: Record<ModelType, ModelCapabilities> = {
  [ModelType.GPT4]: {
    maxTokens: 8192,
    languages: ["en", "zh", "ja", "ko"],
    specialties: ["creative", "technical", "analysis"],
    costPerToken: 0.00003,
    responseTime: "medium"
  },
  [ModelType.GPT35]: {
    maxTokens: 4096,
    languages: ["en", "zh", "ja", "ko"],
    specialties: ["general", "conversation"],
    costPerToken: 0.000001,
    responseTime: "fast"
  },
  [ModelType.CLAUDE]: {
    maxTokens: 100000,
    languages: ["en", "zh"],
    specialties: ["analysis", "reasoning", "long_context"],
    costPerToken: 0.00002,
    responseTime: "medium"
  },
  [ModelType.QWEN]: {
    maxTokens: 6000,
    languages: ["zh", "en"],
    specialties: ["chinese_content", "technical"],
    costPerToken: 0.00001,
    responseTime: "fast"
  },
  [ModelType.ERNIE]: {
    maxTokens: 4096,
    languages: ["zh"],
    specialties: ["chinese_content", "creative"],
    costPerToken: 0.000012,
    responseTime: "fast"
  },
  [ModelType.SPARK]: {
    maxTokens: 4096,
    languages: ["zh", "en"],
    specialties: ["multimodal", "general"],
    costPerToken: 0.000015,
    responseTime: "medium"
  },
  [ModelType.KIMI]: {
    maxTokens: 128000,
    languages: ["zh", "en"],
    specialties: ["long_context", "research"],
    costPerToken: 0.000012,
    responseTime: "slow"
  },
  [ModelType.DEEPSEEK]: {
    maxTokens: 4096,
    languages: ["en", "zh"],
    specialties: ["code", "math", "technical"],
    costPerToken: 0.000008,
    responseTime: "fast"
  },
  [ModelType.DOUBAO]: {
    maxTokens: 4096,
    languages: ["zh"],
    specialties: ["conversation", "general"],
    costPerToken: 0.00001,
    responseTime: "fast"
  },
  [ModelType.HUNYUAN]: {
    maxTokens: 4096,
    languages: ["zh"],
    specialties: ["general", "knowledge"],
    costPerToken: 0.000011,
    responseTime: "medium"
  }
};

export const PARAMETER_PRESETS: Record<string, ParameterPreset> = {
  creative: {
    id: "creative",
    name: "创意模式",
    description: "适合创意写作、故事创作",
    parameters: {
      temperature: 0.9,
      topP: 0.95,
      maxTokens: 2000,
      presencePenalty: 0.5,
      frequencyPenalty: 0.5
    }
  },
  balanced: {
    id: "balanced",
    name: "平衡模式",
    description: "适合一般内容生成",
    parameters: {
      temperature: 0.7,
      topP: 0.85,
      maxTokens: 1500,
      presencePenalty: 0.3,
      frequencyPenalty: 0.3
    }
  },
  precise: {
    id: "precise",
    name: "精确模式",
    description: "适合事实性内容、技术文档",
    parameters: {
      temperature: 0.3,
      topP: 0.75,
      maxTokens: 1000,
      presencePenalty: 0,
      frequencyPenalty: 0
    }
  }
};